import axiosResquest from "@/axios/axiosResquest.js";
import {JSEncrypt} from "jsencrypt";

export const getPublicKey = () => {
    return axiosResquest.get("/user/publicKey");
}
export const regist = (param) => {
    return axiosResquest.post("/user/regist", param);
}

export const getEncodePassword = async (password) => {
    const {code, msg, data: publicKey } = await getPublicKey();
    const encrypt = new JSEncrypt();
    encrypt.setPublicKey(publicKey);
    const encodePassword = encrypt.encrypt(password);
    return encodePassword;
}

export const login = (param) => {
    return axiosResquest.post("/user/login", param);
}